# 1、删除列表里所有字符串对象

"""a1_list = [1,2,3,"bian",5,4,"shen","zhi","hou","丁莹"]
b1_list = list()
for i in a1_list:
    if type(i) == str:
        b1_list.append(i)
for j in b1_list:
    for k in a1_list:
        if j == k:
            a1_list.remove(k)
print(a1_list)
"""
# 2、删除列表中重复的元素
a2_list = [1,2,3,4,5,1,1,2,6,7]
"""for i in a2_list:
    if a2_list.count(i) >= 2:
        a2_list.remove(i)
print(a2_list)"""

"""b2_list = list()
for i in a2_list:
    if a2_list.count(i) >= 2:
        b2_list.append(i)
for j in b2_list:
    for k in a2_list:
        if j == k:
            a2_list.remove(k)
print(a2_list)
"""

# 3、l1 = [1, 2, 3, 4, 5]
l1 = [1, 2, 3, 4, 5]
# （1）在l1的元素3后面插入300

"""l1 = [1, 2, 3, 4, 5]
l1.insert(3,300)
print(l1)"""

# （2）删除元素2

"""l1.remove(2)
print(l1)
"""
# （3）将5更改为500

"""l1[4] = 500
print(l1)"""

# （4）将2，3，4切片出来

"""print(l1[1:4])"""

# （5）l1[-3:-5]的结果   # [1]

"""# [1]
print(l1[-3:-5])"""

# （6）l1[-3:]的结果

"""# [3,4,5]
print(l1[-3:])"""

# 4. 通过input引导用户输入一个姓名，判断该姓名是否存在于列表names中

"""names = ["沈腾","艾伦","马丽","袁华","小沈阳"]
name = input("请输入你的名字：")

if name in names:
    print("名字在列表中")
else:
    print("名字不在列表中")"""


# 5、l = [1,2,3,[4,5]]
l = [1,2,3,[4,5]]
# （1）将4修改为400

"""l[3][0] = 400
print(l)"""

# （2）在l的[4，5]列表中追加一个6，即使l变为[1,2,3,[4,5,6]]

"""a5_list = l[3]
a5_list.append(6)
print(l)"""

# 6、计算数值型列表的平均值是多少？

"""a6_list = [1,2,3,4,5,6,7]
a6 = len(a6_list)
b6 = sum(a6_list)
print(b6 / a6)"""

# 7、从数值型列表中，将索引位置为偶数的，挑选出来，放到一个新列表里

"""a7_list = [1,2,3,4,5,6,7,8,9]
b7_list = list()
for i in a7_list:
    if a7_list.index(i) %2 == 0:
        b7_list.append(i)
print(b7_list)"""


# 8、求出列表里最大的数是多少（不允许用sort等其他内置函数去做）,以及这个数所在的索引位置

"""b8_list = [1,5,3,7,10,21,99,22]
a8 = 0 # 存放最大的数
b8 = 0 # 存放索引
for i in b8_list:
    if a8 <= i:
        a8 = i
        b8 = b8_list.index(i)
print(b8)
print(a8)"""

# 9、学生管理系统：打印功能菜单、添加学生信息、删除学生信息、修改学生信息、显示学生信息、退出系统，并且需要接收用户的输入，
# 在根据输入内容调用相应函数实现相应功能，模板图如下

"""stu_iist = []
while True:
    print("欢迎来到学生管理系统：")
    print("*"*15)
    print("功能菜单：","①、添加学生信息","②、删除学生信息","③、显示学生信息","④、显示学生系统","⑤、退出系统",sep = "\n")
    print("*"*15)
    key = int(input("请输入功能菜单对应的数字："))
    if key == 1: # 添加学生信息
        stu_name = input("请输入学生信息：")
        if stu_name not in stu_iist:
            stu_iist.append(stu_name)
            print("添加学生信息成功！！！")
        else:
            print("添加学生信息失败！！！")
    elif key == 2: # 删除学生信息
        stu_name = input("请输入要删除的学生信息：")
        if stu_name in stu_iist:
            stu_iist.remove(stu_name)
            print("删除学生信息成功！！！")
        else:
            print("删除学生信息失败！！！")
    elif key == 3: # 修改学生信息
        stu_name_old = input("请输入你要修改的学生信息：")
        if stu_name_old in stu_iist:
            stu_name_new = input("请输入修改后的学生姓名：")
            i = stu_iist.index(stu_name_old)
            stu_iist[i] = stu_name_new
            print("修改学生信息成功！！！")
        else:
            print("修改学生姓名失败！！！")

    elif key == 4: # 展示学生姓名
        for index,value in enumerate(stu_iist):
            print(f"第{index+1}名学生是{value}")
    elif key == 5:
        print("感谢使用学生管理系统")
        break
    else:
        print("输入错误数字")"""

"""print("欢迎来到学生管理系统！！！")
print("*" * 15)
print("功能菜单：", "①、添加学生信息", "②、删除学生信息", "③、修改学生信息", "④、显示学生信息", "⑤退出系统", sep="\n")
print("*" * 15)
add_stu_message = list()
while True:
    key = input("输入对应功能的数字：")
    if key == "1":
        name = input("请输入名字：")
        add_stu_message.append(name)
        age = int(input(("请输入年龄：")))
        add_stu_message.append(age)
        sex = input("请输入性别：")
        add_stu_message.append(sex)
    elif key == "2":
        name1 = input("输入要删除的姓名：")
        if name1 in add_stu_message:
            add_stu_message.remove(name1)  #删除学生信息
        else:
            print("没有要删除的姓名！！！")
        age1 = input("输入要删除的年龄：")
        if age1 in add_stu_message:
            add_stu_message.remove(age1)
        else:
            print("没有要删除的年龄！！！")
        sex1 = input("输入要删除的性别：")
        if sex1 in add_stu_message:
            add_stu_message.remove(sex1)
        else:
            print("没有要删除的性别！！！")
    elif key == "3":
        name2 = input("请输入要修改的名字：")
        if name2 in add_stu_message:
            name3 = input("修改后的名字：")
            pass
            pass
            pass
        else:
            print("要修改的名字不存在")
        #修改学生信息
    elif key == "4":
        print(add_stu_message) #显示学生信息
    elif key == "5":
        key1 = input("您真的要退出吗？是/否   :")
        if key1 == "是":
            break
    else:
        pass #输入错误"""

# 10、计算传入的string中,数字,字母,空格以及其它内容的个数,并返回结果



"""a10_str = "123 abdc 569 说话 look my eyes"
str_a = "abcdefghijklmnopqrstuvwxyzABCDEFJHIJKLMNOPQRSTUVWXYZ"
str_b = "0123456789"
n10 = 0 # 计算数字的个数
ch = 0 # 计算字母的个数
kg = 0 # 计算空格个数

for sz in a10_str:
    for i in str_b:
        if i == sz:
            n10 += 1
for k in str_a:
    for zimu in a10_str:
        if k == zimu:
            ch += 1
for l in a10_str:
    if l == " ":
        kg += 1
len10 = len(a10_str)
print(len10)
print(type(len10))
qt = len10 - n10 - ch - kg
print(f"数字的个数是{n10},字母的个数是{ch},空格的个数是{kg},其他的个数是{qt}")
"""

# 11、一行代码实现1~100的和
"""print(sum([i for i in range(1, 101)]))"""

# 12、删除列表中所有重复元素，使得每个元素只出现一次

"""a12_str = [1,2,3,"aa","bb","aa",5,1,1,2,8,9]
for i in a12_str:
    if a12_str.count(i) >= 2:
        a12_str.remove(i)
print(a12_str)"""


# 13、todo:从0~9的十个数字中随机取出4个不重复的数字组成一个字符串，将四个字符串放入列表中
import random

"""str13 = "0123456789"
str_13 = ""
result = []
while True:
    ran_num_1 = random.choice(str13)
    if ran_num_1 not in str_13:
        str_13 += ran_num_1
    elif str_13[0] == '0':
        str_13 = str_13[1:]
    if len(str_13) >= 4:
        result.append(str_13[:4])
        str_13 = ""
    elif len(result) == 4:
        break
print(result)
"""
"""str1_13 = str(random.sample(range(0, 10), 4))
str2_13 = str(random.sample(range(0, 10), 4))
str3_13 = str(random.sample(range(0, 10), 4))
list_13 = list()
list_13.append(str1_13)
list_13.append(str2_13)
list_13.append(str3_13)
print(list_13)
print(type(list_13))"""

# 14、判断输入的数字是否大于150

"""n14 = int(input("请输入数字："))
if n14 > 150:
    print("该数字大于150")
else:
    print("该数字小于等于150")"""

# 13、todo:从0~9的十个数字中随机取出4个不重复的数字组成一个字符串，将四个字符串放入列表中

"""str1 = "0123456789"
str_1 = ""
result = []

while True:
    ran_num = random.choice(str1)
    if ran_num not in str_1:
        str_1 += ran_num
    elif str_1[0] == "0":
        str_1 = str_1[1:]
    elif len(str_1) >= 4:
        result.append(str_1[:4])
        str_1 = ""
    elif len(result) == 4:
        break
print(result)"""
